<template>
  <el-card class="app-container">
    <c-u-r-d-table :option="option"/>
  </el-card>
</template>

<script>

import ColumnType from '@/framework/constant/ColumnType'
import TargetTypeEnum from '@/feature/mms/infra/constants/TargetTypeEnum'
import {noticeApi} from '@/feature/mms/infra/api/noticeApi'
import CURDTable from '@/framework/components/table/CURDTable'
import {roleApi} from "@/feature/mgr/infra/api/roleApi";
import YesNoEnum from "@/infra/constant/YesNoEnum";

export default {
  components: {CURDTable},
  data() {
    return {
      option: {
        requestApi: noticeApi,
        requestApiNames: {
          list: 'myMsgPage'
        },
        showSelection: false,
        columns: [
          {
            label: '标题',
            searchable: true,
            span: 24,
            required: true,
            prop: 'title',
            renderOptions: {
              maxlength: 64
            }
          },
          {
            label: '描述',
            prop: 'intro',
            width: 'auto',
            span: 24,
            required: true,
            type: ColumnType.RICH_TEXTAREA,
            renderOptions: {
              maxlength: 255
            }
          }, {
            label: '内容',
            prop: 'content',
            width: 'auto',
            span: 24,
            hiddenInTable: true,
            viewDetail: true,
            type: ColumnType.RICH_EDITOR
          },
          {
            label: '是否已读',
            type: ColumnType.RADIO,
            prop: 'readFlag',
            options: YesNoEnum
          },
          {
            label: '消息时间',
            type: ColumnType.DATETIME,
            hiddenInForm: true,
            prop: 'gmtCreate'
          }
        ]
      }
    }
  },
  methods: {
    handleSetRead({arg: row}) {
      noticeApi.read(row.id).then(() => {
        row.readFlag = 1
      })
    },
    handleSetReadAll({$service}) {
      noticeApi.readAll().then(() => {
        $service.reloadTable()
        // this.$message.success('')
      })
    }
  }
}
</script>

